import { Get, Post, BaseService } from "@/utils/http";

export interface GetUserParams {
  id: number;
}
export interface CreateUserParams {
  name: string;
  age: number;
}
export interface User {
  id: number;
  name: string;
  age: number;
}

export interface loginParams {
  username: string;
  password: string;
}

/**
 * 用户服务类
 */
export class UserService extends BaseService {
  @Get("/users/{id}", { cancelable: true, noToken: true })
  async getUserWithoutToken(params: GetUserParams) {
    return this.executeMethod<GetUserParams, User>(params);
  }

  // @Post("/users", { cancelable: true, retry: 3 })
  // async createUserWithRetry(data: CreateUserParams) {
  //   return this.executeMethod<void, User>(undefined, data);
  // }

  // @Put("/users/{id}", { noToken: true })
  // async updateUserWithoutToken(params: GetUserParams, data: Partial<User>) {
  //   return this.executeMethod<GetUserParams, User>(params, data);
  // }
  @Post("/api/user/login")
  async login(params: loginParams) {
    return this.executeMethod(params);
  }
}
